<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="vlms.bean.Movie"%>
<%@ page import="vlms.service.*" %>
<%
VLMSServiceProxy proxy = new VLMSServiceProxy();  
proxy.setEndpoint("http://localhost:8080/VLMS/services/VLMSService");
Movie[] movieList=null;
try
{
	System.out.println("called..");

request.setAttribute("flag","display");
	movieList=proxy.listAllMovies();


}
catch(Exception e)
{
	String message=e.getMessage();
	e.printStackTrace();
	request.setAttribute("message", message);
	RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/adminHome.jsp");
	dispatcher.forward(request, response);
}
	
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>DisplayAllMovies</title>
</head>
<body>
<table width="100%">
<%@ include file="/header.jsp" %>

<tr valign="top"><td align="center" height="300px">
<table width="100%" border="1">

<tr valign="top" height="50px">
<td align="center">
<%@ include file="/headerLinks.jsp" %>
</td>
</tr>
<tr><td align="center" height="40px" colspan="2" valign="top"><h3>Search and Delete a Movie</h3></td></tr>
<% if(request.getAttribute("message") != null) { %>
<tr><td align="center" style="color:red"><%= request.getAttribute("message") %></td></tr>
<% } %>
<tr>
<td>
<table border="1">
				
				<%
				if(movieList!=null)
				{
						
						
				%>
				<tr>
					
					<td align="right">
					<label name="moviename" style="size: 30;">Movie Name</label>
					</td>
					<td align="right">
					<label name="moviebanner" style="size: 30;">Movie Banner</label>
					</td>
					<td align="right">
					<label name="moviecategory" style="size: 30;">Movie Category</label>
					</td>
					<td align="right">
					<label name="releasedate" style="size: 30;">Release Date</label>
					</td>
					<td align="right">
					<label name="rentamount" style="size: 30;">Rent Amount</label>
					</td>
					
				</tr>
				
				<%
				
				for(Movie movie: movieList)
				{
					if(movie.getCopiesavailable()>0)
					{
				%>
				
				<form name="row" method="post" action="HandleDisplayMovie">
				<table border="1">
				<tr >
				<td>
				
					<td><label
						name="movieName" style="size: 30;"><%=movie.getMoviename()%></label>
					</td>
					<td ><label
						name="movieBanner" style="size: 30;"><%=movie.getMoviebanner()%></label>
					</td>
					<td><label
						name="movieCategory" style="size: 30;"><%=movie.getCategory()%></label>
					</td>
					<% Calendar c= movie.getReleasedate();
					java.util.Date d=new java.util.Date(c.getTimeInMillis());
					
					
					%>
					
					<td><label
						name="releaseDate" style="size: 30;"><%=new SimpleDateFormat("yyyy-mm-dd").format(d)%></label>
					</td>
					<td ><label
						name="rentAmount" style="size: 30;"><%=movie.getRentamount()%></label>
					</td>
					<td>
					<input type="hidden" name="hidden" value='<%=movie.getMovieid()%>' />
					<input type="submit" value='Delete'
						name="submit" />
					<input type="submit" value='List Person' name="submit" />

				</tr>
				</table>
				</form>
				
				<%
				}
				}
				
				}
				%>
      </table>

</td>
</tr>
</table>

<%@ include file="/bottom.html" %>
</table>
</body>
</html>